using System;

namespace LightPersist.Metainfo
{
	/// <summary>
	/// Define custom initializer of property for construction code serializer
	/// </summary>
	[AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = true)]
	public sealed class CodeInitializerAttribute : Attribute
	{
		/// <summary>
		/// Define custom initializer of property for construction code serializer
		/// </summary>
		/// <param name="codePattern">Code pattert, e.g. 'typeof({0})'</param>
		/// <param name="args">List of argument properties to pattern, e.g. 'TypeName, where TypeName is an internal property of type string</param>
		public CodeInitializerAttribute(string codePattern, params string[] args)
		{
			if (string.IsNullOrEmpty(codePattern))
			{
				throw new ArgumentNullException("codePattern");
			}
			CodePattern = codePattern;
			Args = args;
		}

		public string CodePattern { get; private set; }
		public string[] Args { get; private set; }

	}
}